<?php
include '../service/InvitationService.class.php';
include '../service/UserService.class.php';
include '../util/class.mailhelper.php';
include '../util/class.tools.php';
include '../util/class.log.php';
header("Content-type:text/html;charset=utf-8");
$id = $_POST['id'];
$username = $_POST['username'];
$userService = new UserService();
$aid = $userService->selectUserIDByUsername($username);
$invitation = new InvitationService();
$result = $invitation->updatePostStatusById($id,$aid);
$r = $invitation->getUserEmailByPostId($id);
$email = $r[0] ;$content = $r[1];
$username = $r[2];
$sendMail = new mailhelper();
$sendMail->updateStatus($username, $email, $content);
if($result == 0) {
	$L = log::get_instance();
	$L->log(0,'用户'.$username.'更新帖子状态失败', date('Y-n-j H:m:s'));
	$L->close();
	$array = array('tip' => 0);       //修改失败
	print_r(json_encode($array));
}else {
	$L = log::get_instance();
	$L->log(0,'用户'.$username.'更新帖子状态成功', date('Y-n-j H:m:s'));
	$L->close();
	$array = array('tip' => 1);       //修改成功
	print_r(json_encode($array));
}